¿Cómo creo una función con un valor después?
p.ej
function gotolocation(href) { href = href + "?search=stackoverflow"; window.location = href; } gotolocation.href = "https://google.com";Podrías usar Setter
const gotolocation = { set href(url) { url += "?search=stackoverflow"; window.location = url; } }; gotolocation.href = "https://google.com"; pero en tal caso, gotolocation sería un objeto con una función Setter vinculada a la propiedad href , no una función en sí.
Si su pregunta era: "Cómo usar esta función"
que la respuesta es simple: su función acepta un argumento, así que pase uno:
gotolocation("https://google.com");Puede crear un objeto con función, como una clase en OOP;
const location = { href: "https://facebook.com", goto: () => { let link = location.href + "?search=stackoverflow"; window.location = link; } } location.href = "https://google.com"; location.goto();puedes pasar un valor a una función
gotolocation("https://google.com");